<%@ Control Language="C#" AutoEventWireup="true" CodeFile="FileList.ascx.cs" Inherits="ScrewTurn.Wiki.FileList" %>
<%@ Register TagPrefix="st" TagName="Captcha" Src="~/Captcha.ascx" %>

<asp:Literal ID="lblInfo" runat="server" meta:resourcekey="lblInfoResource1"></asp:Literal>
<div>
	<div style="float: left;">
		<st:Captcha ID="captcha" runat="server" />
	</div>
	<asp:FileUpload ID="updFile" runat="server" size="60" meta:resourcekey="updFileResource1" />
	<asp:CheckBox ID="chkOverwrite" runat="server" Text="Overwrite existing File" meta:resourcekey="chkOverwriteResource1" /><br />
	<div id="ButtonDiv">
		<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" meta:resourcekey="btnUploadResource1" />
		<asp:Label ID="lblResult" runat="server" meta:resourcekey="lblResultResource1"></asp:Label>
	</div>
	<div id="ProgressDiv" style="display: none;">
		<img src="Images/Wait.gif" alt="Uploading..." />
	</div>
</div>
<br /><br />

<script type="text/javascript">
<!--
    function __PrepareRename(name, type) {
        __GetServerElementById("lstFiles_txtOldName").value = name;
        document.getElementById("OldNameSpan").innerHTML = name;
        __GetServerElementById("lstFiles_txtItemType").value = type;
        __GetServerElementById("lstFiles_txtNewName").value = "";
        document.getElementById("ItemRenameDiv").style["display"] = "";
        __GetServerElementById("lstFiles_txtNewName").focus();
        return false;
    }
    function __CancelRename() {
        __GetServerElementById("lstFiles_txtOldName").value = "";
        document.getElementById("OldNameSpan").innerHTML = "";
        __GetServerElementById("lstFiles_txtItemType").value = "";
        __GetServerElementById("lstFiles_txtNewName").value = "";
        document.getElementById("ItemRenameDiv").style["display"] = "none";
        return false;
    }
// -->
</script>

<div id="ItemRenameDiv" style="display: none;">
<h3 class="separator"><asp:Literal ID="lblRename" runat="server" Text="Rename Item" meta:resourcekey="lblRenameResource1"></asp:Literal></h3>
<asp:HiddenField ID="txtItemType" runat="server" />
<asp:HiddenField ID="txtOldName" runat="server"></asp:HiddenField>
<span id="OldNameSpan"></span><br />
<asp:TextBox ID="txtNewName" runat="server" Width="250px" meta:resourcekey="txtNewNameResource1"></asp:TextBox>
<asp:Button ID="btnRename" runat="server" Text="Rename" OnClick="btnRename_Click" meta:resourcekey="btnRenameResource1" />
<a href="#" onclick="javascript:return __CancelRename();"><asp:Literal ID="lblCancel" runat="server" Text="Cancel" meta:resourcekey="lblCancelResource1"></asp:Literal></a><br />
<small><asp:Literal ID="lblExtension" runat="server" Text="<b>Note</b>: file extension (if needed) is appended automatically." meta:resourcekey="lblExtensionResource1"></asp:Literal></small>
<br /><br /><br /><br />
</div>

<asp:Literal ID="lblStrings" runat="server" meta:resourcekey="lblStringsResource1"></asp:Literal>

<asp:Literal ID="lblExpandRename" runat="server" meta:resourcekey="lblExpandRenameResource1"></asp:Literal>

<script type="text/javascript">
<!--

    if(__GetServerElementById("lstFiles_txtOldName").value != "")
        document.getElementById("OldNameSpan").innerHTML = __GetServerElementById("lstFiles_txtOldName").value;

    function __ConfirmOperation() {
        if(window.confirm(__ConfirmMessage)) return true;
        else return false;
    }
// --> 
</script>

<asp:Button ID="btnDeleteSelected" runat="server" Text="Delete Selected" OnClick="btnDeleteSelected_Click" meta:resourcekey="btnDeleteSelectedResource1" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="txtNewDirectory" runat="server" Width="250px" meta:resourcekey="txtNewDirectoryResource1"></asp:TextBox>
<asp:Button ID="btnNewDirectory" runat="server" Text="New Directory" OnClick="btnNewDirectory_Click" meta:resourcekey="btnNewDirectoryResource1" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btnRefresh" runat="server" Text="Refresh" meta:resourcekey="btnRefreshResource1" />
<asp:HiddenField ID="txtCurrentDirectory" runat="server" />
<asp:Literal ID="lblFileList" runat="server" meta:resourcekey="lblFileListResource1"></asp:Literal>

<script type="text/javascript">
<!--
   
     __GetServerElementById("lstFiles_btnUpload").onclick = __CheckFileExtension;
    
    <% PrintFileExtensions(); %>
    function __CheckFileExtension() {
        var file = __GetServerElementById("lstFiles_updFile").value.toLowerCase();
        if(file.length == 0) return true;
        
        var found = 0;
        for(i = 0; i < __ext.length; i++) {
            if(file.substring(file.length - __ext[i].length) == __ext[i]) {
                found = 1;
                break; 
            }
        }
        if(found == 0) {
            window.alert(__message);
            return false;
        }
        
        document.getElementById("ButtonDiv").style["display"] = "none";
        document.getElementById("ProgressDiv").style["display"] = "";
        return true;
    } 
// -->
</script>
